package work.jame.blog.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;
import work.jame.blog.framework.VerificationGroup;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

/***
 * @author Jame
 * @since 2023-05-09
 */
@TableName("user")
@ApiModel(description = "用户类")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户id")
    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class,VerificationGroup.Update.class})
    private Long id;

    /**
     * 用户昵称
     */
    @ApiModelProperty(value = "用户昵称")
    @Length(min = 1,max = 20,message = "昵称长度不符合规范", groups = VerificationGroup.Update.class)
    @NotNull(message = "昵称不能为空",groups = VerificationGroup.Update.class)
    @Null(message = "非法参数",groups = VerificationGroup.Save.class)
    @TableField("nick_name")
    private String nickName;


    /**
     * 用户邮箱
     */
    @ApiModelProperty(value = "用户邮箱")
    @TableField("email")
    @NotNull(message = "用户邮箱不能为空",
            groups = {VerificationGroup.Save.class, VerificationGroup.Login.class})
    @Email(message = "邮箱格式不正确")
    @Length(max = 100, message = "邮箱格式不正确", groups = VerificationGroup.Save.class)
    private String email;


    /**
     * 密码
     */
    @ApiModelProperty(value = "用户加密后的密码")
    @NotNull(message = "密码不符合要求",
            groups = {VerificationGroup.Login.class,
                    VerificationGroup.Save.class})
    @Length(min = 8, max = 30, message = "密码不符合要求",
            groups = {VerificationGroup.Login.class,
                    VerificationGroup.Save.class})
    @TableField("password")
    private String password;


    /**
     * 头像资源名称
     */
    @ApiModelProperty(value = "头像资源名称")
    @TableField("avatar_resource_name")
    private String avatarResourceName;


    /**
     * 个性签名
     */
    @ApiModelProperty(value = "个性签名")
    @TableField("personalized_signature")
    @Length(max = 200,message = "")
    private String personalizedSignature;

    /**
     * 生日
     */
    @ApiModelProperty(value = "用户生日")
    @TableField("birthday")
    private LocalDate birthday;


    /**
     * 用户状态 0正常 1封禁
     */
    @ApiModelProperty(value = "用户状态 0正常 1封禁")
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    @TableField("status")
    private Integer status;

    /**
     * 0男 1女 2阿帕奇武装直升机
     */
    @ApiModelProperty(value = "用户性别 0男 1女 2阿帕奇武装直升机")
    @TableField("sex")
    private Integer sex;

    /**
     * 用户的经验值
     */
    @ApiModelProperty(value = "用户的经验值")
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    @TableField("exp")
    private Integer exp;


    /**
     * 用户拥有的米粒数
     */
    @ApiModelProperty(value = "用户拥有的米粒数")
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    @TableField("rice_grain_number")
    private Double riceGrainNumber;

    @TableField("deleted")
    @TableLogic
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    @JsonIgnore
    private Boolean deleted;

    @TableField(value = "insert_time", fill = FieldFill.INSERT)
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    private LocalDateTime insertTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(hidden = true)
    @Null(message = "非法传入参数", groups = {VerificationGroup.Save.class, VerificationGroup.Update.class})
    private LocalDateTime updateTime;


    public String getPersonalizedSignature() {
        return personalizedSignature;
    }

    public void setPersonalizedSignature(String personalizedSignature) {
        this.personalizedSignature = personalizedSignature;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public LocalDateTime getInsertTime() {
        return insertTime;
    }

    public void setInsertTime(LocalDateTime insertTime) {
        this.insertTime = insertTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public String getAvatarResourceName() {
        return avatarResourceName;
    }

    public void setAvatarResourceName(String avatarResourceName) {
        this.avatarResourceName = avatarResourceName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getExp() {
        return exp;
    }

    public void setExp(Integer exp) {
        this.exp = exp;
    }

    public Double getRiceGrainNumber() {
        return riceGrainNumber;
    }

    public void setRiceGrainNumber(Double riceGrainNumber) {
        this.riceGrainNumber = riceGrainNumber;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", nickName='" + nickName + '\'' +
                ", email='" + email + '\'' +
                ", password='" + password + '\'' +
                ", avatarResourceName='" + avatarResourceName + '\'' +
                ", personalizedSignature='" + personalizedSignature + '\'' +
                ", birthday=" + birthday +
                ", status=" + status +
                ", sex=" + sex +
                ", exp=" + exp +
                ", riceGrainNumber=" + riceGrainNumber +
                ", deleted=" + deleted +
                ", insertTime=" + insertTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
